package com.addressbook.fw;

import java.util.List;

import org.openqa.selenium.By;
//import org.openqa.selenium.NoSuchElementException;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;

public class HelperWithWebDriverBase extends HelperBase{

	private WebDriver driver;

	public HelperWithWebDriverBase(ApplicationManager manager) {
		super(manager);
		driver = manager.getWebDriverHelper().getDriver();
	}

	protected void fillField(String locator, String name) {
		driver.findElement(By.name(locator)).clear();
		driver.findElement(By.name(locator)).sendKeys(name);
	}

//	private boolean isElementPresent(By by) {
//		try {
//			driver.findElement(by);
//			return true;
//		} catch (NoSuchElementException e) {
//			return false;
//		}
//	}

	protected WebElement findElement(By name) {
		return driver.findElement(name);
	}
	
	protected List<WebElement> findElements(By name) {
		return driver.findElements(name);
	}

	protected void openUrl(String url) {
		driver.get(url);
	}

	protected void click(By name) {
		findElement(name).click();
	}
}
